package org.Niu.July8th.collectionTest.mapTest;

import java.util.HashMap;
import java.util.Map;

public class mapTest01 {
    public static void main(String[] args) {
        // 1. 遍历key - keySet()
        Map<String,Integer> mp = new HashMap<>();
        mp.put("zhangsan",18);
        mp.put("lisi",19);
        mp.put("wangwu",16);

        for(String item : mp.keySet()){
            System.out.println(mp.get(item));
        }

        // 2. 遍历整体 - entrySet() - 遍历时不保证顺序
        for (Map.Entry<String, Integer> stringIntegerEntry : mp.entrySet()) {
            System.out.println("stringIntegerEntry.getKey() = " + stringIntegerEntry.getKey());
            System.out.println("stringIntegerEntry.getValue() = " + stringIntegerEntry.getValue());
        }

    }
}
